|
|
|
|
|
|
|
Even though Dynasets are virtual tables in memory created from physical tables, they are not static copies of the data table. After you create a Dynaset, if anyone else alters the underlying data table by modifying, adding, or deleting records, you see the changes in your Dynaset as soon as you refresh the Dynaset. Refreshing the Dynaset can be done using the Refresh method. You can also refresh the Dynasets by moving the record pointer using the arrow keys of the data control or using the MoveFirst, MoveNext, MovePrevious, and MoveLast methods. Moving the pointer refreshes only the records you read, not the entire Dynaset. |
|
|
|
|
|
|
|
|
Although the dynamic aspect of Dynasets is very effective in maintaining up-to-date views of the underlying data table, Dynasets also have some limitations and drawbacks. For example, if another user deletes a record that you currently have in your Dynaset and you attempt to move to that record, Visual Basic reports an error. |
|
|
|
|
|
|
|
|
Dynasets Can Be Created from More Than One Table |
|
|
|
|
|
|
|
|
A Dynaset can be created using more than one table in the database. You can create a single view that contains selected records from several tables, update the view, and therefore update all the underlying tables of the data at one time. This is a very powerful aspect of a Visual Basic Dynaset data object. Using Visual Basic Dynasets, you can create virtual tables that make it easy to create simple data entry screens and display graphs and reports that show specialized selections of data. |
|
|
|
|
|
|
|
|
Use Dynasets to Create Other Dynasets or Snapshots |
|
|
|
|
|
|
|
|
Often in Visual Basic programs, you need to create a secondary dataset based on user input. The Dynaset data object is the only data object from which you can create another Dynaset. |
|
|
|
|
|
|
|
|
You can create additional Dynasets by using the Clone method or the CreateDynaset method. When you clone a Dynaset, you create an exact duplicate of the Dynaset. You can use this duplicate to perform look-ups or to reorder the records for a display. Cloned Dynasets take up slightly less room than the original Dynaset. |
|
|
|
|
|
|
|
|
Let's put together a short code sample that explores Dynasets. You do this all in Visual Basic code, too, instead of using the Visual Basic data control. |
|
|
|
|
|
|
|
|
First start a new Visual Basic 5.0 Standard EXE project. Be sure to add a reference to the Microsoft DAO 3.5 Object Library before you begin coding. To do this, Select Project | References from the Main menu (see Figure 3.2). |
|
|
|
|
|